 <?php
session_start();
include 'nav.inc.php';
include 'dbConn.php';
html_head_without_openings('Verteilerübersicht');

echo("<link rel='stylesheet' type='text/css' href='tcal.css' />");
echo("<link rel='stylesheet' type='text/css' href='styleVerteiler.css' />");
echo("<script type='text/javascript' src='tcal.js'></script>\n");
echo("<script type='text/javascript' src='get_GrpByMA.js'></script>\n");


if(!isset($_SESSION["username"]) || !isset($_SESSION['std']))
{
	echo("</head>");
	echo("<body>");
	echo("<div class='content'>");
	echo ("Bitte erst <a href='../login.php'>einloggen</a>.");
	
	echo("</div>");
	echo("</body>");
	echo("</html>");
}  
else
{
	echo "<script type='text/javascript'>
	<!--
	function show(id) {
		document.getElementById('aufgabe_THIDE_'+id).setAttribute('class','link_visible');
		document.getElementById('TXT_'+id).style.display='inline';
		document.getElementById('aufgabe_TITEL_'+id).setAttribute('class','link_invisible');
	}
	function hide(id) {
		document.getElementById('aufgabe_THIDE_'+id).setAttribute('class','link_invisible');
		document.getElementById('aufgabe_TITEL_'+id).setAttribute('class','link_visible');
		document.getElementById('TXT_'+id).style.display='none';
	}
	//-->
	</script>";	

	menu();

	echo "<div class='content'>";
	echo "<h2>Verteilerlisten</h2>";

	echo "Hinweis: Zum aufklappen auf den Titel klicken! <br/><br/>";
	$result = $dbVerteiler->getLists(); 
	while($row = mysql_fetch_array($result))
	{
		echo "	<div id='Liste'>
				<a id='aufgabe_TITEL_".$row['LID']."' class='link_visible' 
					href='javascript://' onclick='show(".$row['LID'].");'>";
		echo "				<div style='float:left;'>".$row['Titel']."</div>";
		echo "				<div style='float:right;'>&darr;</div>
				</a> \n";
		echo "		<a id='aufgabe_THIDE_".$row['LID']."' 
					class='link_invisible'  style='border-bottom: 1px dotted #36C;'
					href='javascript://' onclick='hide(".$row['LID'].");'>";
		echo "				<div style='float:left;'>".$row['Titel']."</div>";
		echo "				<div style='float:right;'>&uarr;</div>
				</a> \n";
		echo "		<div id='TXT_".$row['LID']."' style='display:none'>
					<br/>\n
					<div id='Listinfo'>\n";

		$result2 = $dbVerteiler->getAddressOfList($row['LID']); 
		while($row2 = mysql_fetch_array($result2))
		{
			echo "				<h3>Adresse:</h3>\n";
			echo 				$row2['Adresse']."<br/>";
		}
		echo "				<h3>Beschreibung:</h3>\n";
		echo 				$row['Kurzbeschreibung']."<br/>";

		echo "				<h3>Mitglieder:</h3>\n";
		echo "				<select name='listmembers' size='10' style='width:37em;'>";
		$result2 = $dbVerteiler->getMembersOfListByLID($row['LID']); 
		while($row2 = mysql_fetch_array($result2))
		{
			  echo "			<option>".$row2['Adresse']." (".$row2['Vorname']." ".$row2['Nachname'].")</option>";
		}

		$result2 = $dbVerteiler->getMemberListsOfListByLID($row['LID']); 
		while($row2 = mysql_fetch_array($result2))
		{
			  echo "			<option>".$row2['Adresse']." (Liste: ".$row2['Titel'].")</option>";
		}
		echo "				</select>";
echo "				<h3>Anschreibberechtigte:</h3>\n";
		echo "				<select name='listwriters' size='10' style='width:37em;'>";
		$result2 = $dbVerteiler->getWriteRightMembersOfListByLID($row['LID']); 
		while($row2 = mysql_fetch_array($result2))
		{
			  echo "			<option>".$row2['Adresse']." (".$row2['Vorname']." ".$row2['Nachname'].")</option>";
		}

		$result2 = $dbVerteiler->getWriteRightListsOfListByLID($row['LID']); 
		while($row2 = mysql_fetch_array($result2))
		{
			  echo "			<option>".$row2['Adresse']." (Liste: ".$row2['Titel'].")</option>";
		}
		echo "				</select>";
		echo "				<br/>";
		echo "			</div>
					<br/>
				</div>
			</div>
			<br/>";
	}
	echo "</div>";
}
?>
